project(libutil)

cmake_minimum_required(VERSION 2.4.0)

if(COMMAND cmake_policy)
	cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)


set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -nostdinc -D__DARWIN_UNIX03 -fPIC -w")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdinc -nostdinc++ -D__DARWIN_UNIX03 -fPIC -w")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -nostdlib")
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR}/src/libc/include)
include_directories(${CMAKE_SOURCE_DIR}/src/libc/darwin)
include_directories(${CMAKE_SOURCE_DIR}/src/libc/locale)
include_directories(${CMAKE_SOURCE_DIR}/src/libc/locale/FreeBSD)
include_directories(${CMAKE_SOURCE_DIR}/src/libc/stdtime/FreeBSD)
include_directories(BEFORE ${CMAKE_SOURCE_DIR}/src/external/libcxx/include)
include_directories(${CMAKE_SOURCE_DIR}/src/kernel/libsyscall/wrappers)

set(util_SRCS
	ExtentManager.cpp
	getmntopts.c
	humanize_number.c
	pidfile.c
	realhostname.c
	reexec_to_match_kernel.c
	trimdomain.c
	tzlink.c
	wipefs.cpp
)

set(DYLIB_INSTALL_NAME "/usr/lib/libutil1.0.dylib")
set(DYLIB_COMPAT_VERSION "1.0.0")
set(DYLIB_CURRENT_VERSION "1.0.0")

add_darling_library(util SHARED ${util_SRCS})
make_fat(util)
target_link_libraries(util PRIVATE system cxx)
set_target_properties(util PROPERTIES OUTPUT_NAME "util1.0")

install(TARGETS util DESTINATION libexec/darling/usr/lib)
install(FILES
	reexec_to_match_kernel.3
	realhostname.3
	humanize_number.3
	getmntopts.3
	realhostname_sa.3
	pidfile.3
	wipefs.3
	trimdomain.3
	DESTINATION
		libexec/darling/usr/share/man/man3
)
